package com.cn.xly2023.advice;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLException;

@RestControllerAdvice
public class MyExceptionAdvice {

    @ExceptionHandler(NumberFormatException.class)
    public String check01() {
        return "亲, 你输入的字符串不是一个合法的整数数字";
    }

    @ExceptionHandler(ArrayIndexOutOfBoundsException.class)
    public String check02() {
        return "亲, 数组下标超出指定的长度内容了";
    }

    @ExceptionHandler(SQLException.class)
    public String check03() {
        return "数据库操作失败，请稍候重试";
    }
    //.....

}
